prepare($sql); //$stmt->bindValue(':bib', $bibno); //$stmt->bindValue(':key', $key); $stmt->execute(); $runner = $stmt->fetch(PDO::FETCH_ASSOC); //d($runner); /* $sql = "select " . $table_prefix . "runners.* from " . $table_prefix . "runners where bibno = :bibno"; $stmt = $db->prepare($sql); $stmt->bindValue(':bibno', $bibno, PDO::PARAM_INT); $stmt->execute(); $runner = $stmt->fetch(PDO::FETCH_ASSOC); */ $name = trim($runner['firstname']) . ' ' . trim($runner['lastname']); $name = ucwords(strtolower($name)); if (haveChinese($name)) { $name = $runner['lastname'] . $runner['firstname']; } if (!$runner || $runner['status'] == "DQ") { die("participant not exist"); } $course= "FOUR TRAILS MINI 2023"; // --------------------------------------------------------- $sql = "select * from " . $table_prefix . "result_public where convert(bibno,unsigned) = convert('" . $bibno . "',unsigned) "; //echo $sql; $stmt = $db->prepare($sql); // $stmt->bindValue(':bibno', $bibno, PDO::PARAM_STR); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); //echo date_diff(strtotime($global['start']) - strtotime($result['lateststep_time']) ); //$finishtime_sec = s_datediff('s', $result['lateststep_time'],$global['start']); //d($result ); //die(); if (!$result['duration'] || $result['duration'] == 9999999) { die("Invalid request"); } $finishtime = Duration($result['duration']); $finishtimea = Duration($result['dur_a']); $finishtimeb = Duration($result['dur_b']); $finishtimec = Duration($result['dur_c']); $finishtimed = Duration($result['dur_d']); // /*--------------------------------------------*/ //d($result); //die(); if (strtoupper($result['gender']) == "M") $rank_gender = $result['place_gender'] . ' of ' . $global['runnerscount_m']; if (strtoupper($result['gender']) == "F") $rank_gender = $result['place_gender'] . ' of ' . $global['runnerscount_f']; $rank_course = $result['place_course'] . ' of ' . $global['runnerscount']; /* $name = "XXX XXX XXX"; $rank_course = 8; $rank_gender = 88; */ /*--------------------------------------------*/ $pdf = new FPDI('L', 'mm', 'A4'); //FPDI extends TCPDF $pdf->AddPage(); if ($result['gender'] == "F") { $pages = $pdf->setSourceFile('fourtrailsminicert2025_fa.pdf'); } else { $pages = $pdf->setSourceFile('fourtrailsminicert2025_ma.pdf'); } $page = $pdf->ImportPage(1); //$pdf->useTemplate($page, 0, 0); $pdf->useTemplate($page,null, null, 0, 0, true); // set document information $pdf->SetCreator('SportSystem.hk'); $pdf->SetAuthor('SportSystem.hk'); $pdf->SetTitle('Certificate'); $pdf->SetSubject('Certificate of '. $name); $pdf->SetKeywords('' ); // --------------------------------------------------------- // set font //$pdf->SetFont('helvetica', '', 20); $textcenter = 30; if (strlen($name) > 23 ) { $pdf->SetFont('DroidSansFallback', '', 25, '', true); } else { $pdf->SetFont('DroidSansFallback', '', 30, '', true); } $pdf->SetTextColor(0,0,0); //$pdf->SetXY(50, 30); //$pdf->Write(0, 'This is just a simple text'); $pdf->SetY(45); $pdf->Cell($textcenter); $pdf->Cell(210,20,$name,0,1,'C'); $pdf->SetFont('DroidSansFallback','', 20); /* $pdf->SetY(68); $pdf->Cell($textcenter); $pdf->Cell(210,15,$course,0,1,'C'); */ /* $pdf->SetFont('DroidSansFallback','', 19); $pdf->writeHTMLCell(120, 15, 63, 87, $course, '1', 1, 1, true, 'C', true); */ $pdf->SetFont('DroidSansFallback','', 18); $pdf->SetY(78); if ($result['gender'] == "F") { $pdf->Cell(145); } else { $pdf->Cell(145); } $pdf->Cell(100,15, $rank_gender,0,1,'L'); $pdf->SetFont('DroidSansFallback','', 18); $pdf->SetY(86); $pdf->Cell(145); $pdf->Cell(100,15, $rank_course,0,1,'L'); $pdf->SetFont('DroidSansFallback','', 16); $pdf->SetY(99); $pdf->Cell(155); $pdf->Cell(100,15, $finishtimea,0,1,'L'); $pdf->SetFont('DroidSansFallback','', 16); $pdf->SetY(108); $pdf->Cell(155); $pdf->Cell(100,15, $finishtimeb,0,1,'L'); $pdf->SetFont('DroidSansFallback','', 16); $pdf->SetY(117); $pdf->Cell(155); $pdf->Cell(100,15, $finishtimec,0,1,'L'); $pdf->SetFont('DroidSansFallback','', 16); $pdf->SetY(126); $pdf->Cell(155); $pdf->Cell(100,15, $finishtimed,0,1,'L'); $pdf->SetFont('DroidSansFallback','', 16); $pdf->SetY(135); $pdf->Cell(155); $pdf->Cell(100,15, $finishtime,0,1,'L'); $filename = "Four Trails Mini2023 Certificate of " . $bibno . '_' . $name . ".pdf"; // --------------------------------------------------------- //Close and output PDF document $pdf->Output($filename , 'I'); //============================================================+ // END OF FILE //============================================================+